//
//  CityCell.m
//  MyTrip
//
//  Created by zhang on 15/8/24.
//  Copyright (c) 2015年 张益. All rights reserved.
//

#import "CityCell.h"
#import "Destination.h"
#import "UIImageView+WebCache.h"
#import "DKNightVersion.h"

@implementation CityCell

- (void)dealloc
{
    [_nameLabel release];
    [_visitImage release];
    [_visitLabel release];
    [_wishImage release];
    [_wishLabel release];
    [_picView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
//        [DKNightVersionManager addClassToSet:self.class];
//        self.nightBackgroundColor = UIColorFromRGB(0x343434);
        self.picView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height - 5)] autorelease];
        [self.contentView addSubview:_picView];
        
        self.nameLabel = [[[UILabel alloc] initWithFrame:CGRectMake(20 * OffWidth, frame.size.height - 80 * OffHeight, 100 * OffWidth, 25 * OffHeight)] autorelease];
        [self.contentView addSubview:_nameLabel];
        
        self.visitImage = [[[UIImageView alloc] initWithFrame:CGRectMake(20 * OffWidth, _nameLabel.frame.size.height + _nameLabel.frame.origin.y, 15 * OffWidth, 15 * OffHeight)] autorelease];
        [self.contentView addSubview:_visitImage];
        
        self.visitLabel = [[[UILabel alloc] initWithFrame:CGRectMake(_visitImage.frame.size.width + _visitImage.frame.origin.x, _nameLabel.frame.size.height + _nameLabel.frame.origin.y, 50 * OffWidth, 20 * OffHeight)] autorelease];
        [self.contentView addSubview:_visitLabel];
        
        self.wishImage = [[[UIImageView alloc] initWithFrame:CGRectMake(_visitLabel.frame.size.width + _visitLabel.frame.origin.x, _nameLabel.frame.size.height + _nameLabel.frame.origin.y, 20 * OffWidth, 20 * OffHeight)] autorelease];
        [self.contentView addSubview:_wishImage];
        
        self.wishLabel = [[[UILabel alloc] initWithFrame:CGRectMake(_wishImage.frame.origin.x + _wishImage.frame.size.width, _nameLabel.frame.size.height + _nameLabel.frame.origin.y, 50 * OffWidth, 20 * OffHeight)] autorelease];
        [self.contentView addSubview:_wishLabel];

    }
    return self;
}


- (void)setValueWithDestination:(Destination *)des{
    
    [_picView sd_setImageWithURL:[NSURL URLWithString:des.cover] placeholderImage:[UIImage imageNamed:@"zhanweitu.jpg"]];
    _picView.layer.cornerRadius = 10;
    _picView.layer.masksToBounds = YES;
    [_nameLabel setText:des.name];
    [_nameLabel setTextColor:[UIColor whiteColor]];
    _nameLabel.shadowColor = [UIColor blackColor];
    _nameLabel.shadowOffset = CGSizeMake(1, 1);
    [_visitLabel setText:[NSString stringWithFormat:@"%ld", des.visited_count]];
    [_visitLabel setTextColor:[UIColor whiteColor]];
    [_visitLabel setFont:[UIFont systemFontOfSize:13]];
    [_visitLabel setTextColor:[UIColor whiteColor]];
    _visitLabel.shadowColor = [UIColor blackColor];
    [_visitImage setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"visit" ofType:@"png"]]];
    [_wishLabel setText:[NSString stringWithFormat:@"%ld", des.wish_to_go_count]];
    [_wishLabel setTextColor:[UIColor whiteColor]];
    [_wishLabel setFont:[UIFont systemFontOfSize:13]];
    [_wishLabel setTextColor:[UIColor whiteColor]];
    _wishLabel.shadowColor = [UIColor blackColor];
    [_wishImage setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"wish" ofType:@"png"]]];
    
}




@end
